package com.lecture.javamode.oop.virtualWallet.ddd;

import com.lecture.javamode.oop.virtualWallet.web.VirtualWalletService;

import java.math.BigDecimal;

/**
 * @author luyn
 * @version 1.0
 * @description 使用传统的贫血模型实现虚拟钱包功能
 * @date 2022/1/10 13:10
 */

public class VirtualWalletController {
    // 通过构造函数或者IOC框架注入
    private VirtualWalletService virtualWalletService;

    //查询余额
    public BigDecimal getBalance(Long walletId) {
        System.out.println("查询余额");
        return BigDecimal.ONE;
    }

    //出账
    public void debit(Long walletId, BigDecimal amount) {
        System.out.println("用户id：" + walletId + "，消费了" + amount + "元");
    }
    //入账
    public void credit(Long walletId, BigDecimal amount) {
        System.out.println("用户id：" + walletId + "，收入了" + amount + "元");
    }

    //转账
    public void transfer(Long fromWalletId, Long toWalletId, BigDecimal amount) {
        System.out.println("用户：" + fromWalletId + "，向用户：" + toWalletId + "，转账了：" + amount + "元");
    }
    //省略查询transaction的接口
}
